import request from '../index';

const baseUrl = '/base-server';
const authUrl = '/auth-server';

// 角色管理-列表查询
export const URL_QUERYROLELIST = `${authUrl}/role/queryPage`;
export const queryRoleList = (params: any, pages: any) => {
  return request({
    url: `${authUrl}/role/queryPage`,
    params: { form: params, pages: pages },
  });
};

// 角色管理-保存
export const saveRole = (params: any) => {
  return request({
    url: `${authUrl}/role/saveRole`,
    params: { form: params, successMsg: '1' },
  });
};

// 角色管理-修改
export const updateRole = (params: any) => {
  return request({
    url: `${authUrl}/role/updateRole`,
    params: { form: params, successMsg: '1' },
  });
};

// 角色管理-详情查询
export const getRoleInfo = (params: any) => {
  return request({
    url: `${authUrl}/role/getRoleInfo`,
    params: { form: params },
  });
};

//管理角色-功能菜单[树形结构]
export const treeData = (params: any) => {
  return request({
    url: `${authUrl}/menuButton/treeData`,
    params: { form: params },
  });
};


//管理角色-角色详情
export const getDetailInfo = (params: any) => {
  return request({
    url: `${authUrl}/role/getDetailInfo`,
    params: { form: params },
  });
};

//角色管理-查询当前登录用户是否有超级管理员选项
export const getAccessAuth = (params: any) => {
  return request({
    url: `${authUrl}/role/getAccessAuth`,
    params: { form: params },
  });
};

//-----------------------------------------------------------------
// 用户管理-列表查询
export const URL_QUERYACCOUNTLIST = `${authUrl}/account/queryPage`;
export const queryAccountList = (params: any, pages: any) => {
  return request({
    url: `${authUrl}/account/queryPage`,
    params: { form: params, pages: pages },
  });
};

//管理员用户-重置密码
export const resetPassword = (params: any) => {
  return request({
    url: `${authUrl}/account/resetPassword`,
    params: { form: params, successMsg: '2' },
  });
};

//B端登录用户-修改密码
export const updatePassword = (params: any) => {
  return request({
    url: `${authUrl}/account/updatePassword`,
    params: { form: params },
  });
};

//管理员用户-冻结
export const freezeAccount = (params: any) => {
  return request({
    url: `${authUrl}/account/freezeAccount`,
    params: { form: params, successMsg: '2' },
  });
};

//管理员用户-恢复
export const enableAccount = (params: any) => {
  return request({
    url: `${authUrl}/account/enableAccount`,
    params: { form: params, successMsg: '2' },
  });
};


//管理员用户-删除
export const deleteAccount = (params: any) => {
  return request({
    url: `${authUrl}/account/deleteAccount`,
    params: { form: params, successMsg: '2' },
  });
};

//管理员用户-保存
export const saveAccount = (params: any) => {
  return request({
    url: `${authUrl}/account/saveAccount`,
    params: { form: params, successMsg: '1' },
  });
};

//管理员用户-修改
export const updateAccount = (params: any) => {
  return request({
    url: `${authUrl}/account/updateAccount`,
    params: { form: params, successMsg: '1' },
  });
};

//管理员用户-修改数据查询
export const queryByAccountId = (params: any) => {
  return request({
    url: `${authUrl}/account/queryByAccountId`,
    params: { form: params },
  });
};

//管理员用户-机构列表
export const userOrgList = (params: any) => {
  return request({
    url: `${baseUrl}/auth/userOrgList`,
    params: { form: params },
  });
};

//管理员用户-角色列表
export const queryRoleTree = (params: any) => {
  return request({
    url: `${authUrl}/account/queryByCreateBy`,
    params: { form: params },
  });
};
